package yja.gzw.app.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import yja.gzw.app.R


class DiminAdapter (private val context: Context, private val list: List<String>,private val listener: OnItemClickListener): RecyclerView.Adapter<RecyclerView.ViewHolder>(){
    interface OnItemClickListener {
        fun onItemClick2(position: Int, uri: String)
    }
    private var view: View?=null
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        view= LayoutInflater.from(parent.context).inflate(R.layout.item_view_diming,parent,false)
        return ViewHodeView(view!!)
    }

    override fun getItemCount(): Int {
      return  list.size
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {

        if(holder is ViewHodeView){
            holder.neirun.text=list[position]

            holder.itemView.setOnClickListener {
                listener.onItemClick2(position, list[position])
            }

        }

    }

    inner class ViewHodeView(itemView: View):RecyclerView.ViewHolder(itemView){
        val neirun: TextView =itemView.findViewById(R.id.didian)


    }





}